<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册界面</title>
</head>
<script src="https://cdn.staticfile.net/jquery/1.10.2/jquery.min.js"></script>
<script>
  $(function () {
    $("#username").blur(function () {
      $.ajax({
        type: "POST",
        url: "/checkName",
        data: {"username": $("#username").val()},//document.getElementById("username").value
        success: function (result) {
          // console.log("result---" + result);
          if (result == "true") {
            $("#msg").html("用户名重复").css("color", "red")
            // document.getElementById("msg").innerHTML = "用户名重复"
          } else {
            $("#msg").html("可以注册").css("color", "green")
            // document.getElementById("msg").innerHTML = "可以注册"
          }
        },
      })
    });
  })
</script>
<body>
<form action="/register" method="post">
  <input type="text" class="form-control" name="username" id="username"
         placeholder="请输入注册账号" autocomplete="off">
  <br/>
  <input type="password" class="form-control" name="password" id="password"
         placeholder="请输入密码">
  <input type="submit" value="注册">
</form>
</body>
</html>